<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    new Promise((resolve, reject) => {
      // 启动异步任务
      setTimeout(() => {
        // 如果成功了
        resolve(1) // pending ==> filfilled
        // 如果失败了
        reject(2) // 状态不会有任何改变
      }, 1000)
    }).then(
      value => {
        console.log('onResolved', value)
        throw 3
      },
      reason => {
        console.log('onRejected', reason)
      }
    ).catch(reason => {
      console.log('onRejected2', reason)
    }).finally(() => {
      console.log('onFinally')
    })

    const p1 = Promise.resolve(4)
    const p2 = Promise.reject(5)
    const p3 = Promise.all([p1, p2])
  </script>
</body>

</html>